package com.yinhai.message.client.tool;

import java.util.List;

import com.yinhai.message.api.bean.TMAppMessage;
import com.yinhai.message.api.bean.TMMessage;
import com.yinhai.message.api.bean.TMUser;
import com.yinhai.message.api.bean.TMWeChat;
import com.yinhai.message.api.web.vo.TMResultVo;
import com.yinhai.message.client.api.TMHttpService;

public class TMHttpUtil {
	public static TMResultVo sendMessage(TMUser sendUser, TMUser receiveUser, TMMessage tmMessage,TMWeChat wechat) throws Exception{
		String resuelt = TMHttpService.getInstance().sendMessage(sendUser, receiveUser, tmMessage,wechat);
		resuelt = resuelt.substring(1, resuelt.length()-1).replaceAll("\\\\", "");
		return com.alibaba.fastjson.JSON.parseObject(resuelt,TMResultVo.class);
	}
	public static TMResultVo sendMessage(TMUser sendUser, List<TMUser> receiveUserList, TMMessage tmMessage,TMWeChat wechat) throws Exception{
		String resuelt = TMHttpService.getInstance().sendMessage(sendUser, receiveUserList, tmMessage,wechat);
		resuelt = resuelt.substring(1, resuelt.length()-1).replaceAll("\\\\", "");
		return com.alibaba.fastjson.JSON.parseObject(resuelt,TMResultVo.class);
	}

	/**
	 * 提供给 低版本MIME 的兼容方法
	 */
	public static TMResultVo sendMessage(TMUser sendUser, List<TMUser> receiveUserList, TMMessage tmMessage,TMWeChat wechat,boolean useMime) throws Exception{
		String resuelt = TMHttpService.getInstance().sendMessage(sendUser, receiveUserList, tmMessage,wechat,useMime);
		resuelt = resuelt.substring(1, resuelt.length()-1).replaceAll("\\\\", "");
		return com.alibaba.fastjson.JSON.parseObject(resuelt,TMResultVo.class);
	}
	/**
	 * app
	 */
	public static TMResultVo sendAppMessage(String aac001s, TMAppMessage appMessage) throws Exception{
		String resuelt = TMHttpService.getInstance().sendAppMessage(aac001s, appMessage);
		resuelt = resuelt.substring(1, resuelt.length()-1).replaceAll("\\\\", "");
		return com.alibaba.fastjson.JSON.parseObject(resuelt,TMResultVo.class);
	}
}
